package com.lb.multithread;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * 利用线程池创建单线程实现队里问题
 * @author jzhang
 * @version 1.0
 * @date 2022/4/2 13:44
 */
public class SeqExecuteTest {
    static ExecutorService executorService = Executors.newSingleThreadExecutor();

    static Thread t1 = new Thread(() -> {
        System.out.println("thread 1");
    });

    static Thread t2 = new Thread(() -> {
        System.out.println("thread 2");
    });

    static Thread t3 = new Thread(() -> {
        System.out.println("thread 3");
    });

    public static void main(String[] args) {
        executorService.submit(t3);
        executorService.submit(t2);
        executorService.submit(t1);
        executorService.shutdown();
    }

}
